import React from "react";
import Axios from "axios";

export default class Demo extends React.Component {
  state = {
    banner: [],
  };

  componentDidMount(): void {
    this.getBanner();
  }

  async getBanner() {
    const res = await Axios.get(
      "http://iwenwiki.com/api/blueberrypai/getIndexBanner.php"
    );
    console.log(res.data.banner);
    this.setState({
      banner: res.data.banner,
    });
  }

  render() {
    return (
      <>
        <div>axios demo</div>

        {this.state.banner.map((item) => {
          console.log(item);
          return <span>{item.title}</span>;
        })} 
      </>
    );
  }
}
